From df30741535aa4698df2f98a2974983554d074f9b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 24 Jun 2020 14:17:15 +0200 Subject: [PATCH] gtkbutton: Drop grab_notify handler The click gesture already has a ::cancel handler, and does almost everything it should. Move the last bits and remove the grab_notify handler. --- gtk/gtkbutton.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index 425bac0675..8a0c084b52 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -140,8 +140,6 @@ static void gtk_button_finish_activate (GtkButton *button, static void gtk_button_state_flags_changed (GtkWidget *widget, GtkStateFlags previous_state); -static void gtk_button_grab_notify (GtkWidget *widget, - gboolean was_grabbed); static void gtk_button_do_release (GtkButton *button, gboolean emit_clicked); static void gtk_button_set_child_type (GtkButton *button, guint child_type); @@ -212,7 +210,6 @@ gtk_button_class_init (GtkButtonClass *klass) widget_class->unrealize = gtk_button_unrealize; widget_class->state_flags_changed = gtk_button_state_flags_changed; - widget_class->grab_notify = gtk_button_grab_notify; widget_class->unmap = gtk_button_unmap; widget_class->compute_expand = gtk_button_compute_expand; widget_class->get_request_mode = gtk_button_get_request_mode; @@ -369,6 +366,11 @@ click_gesture_cancel_cb (GtkGesture *gesture, GdkEventSequence *sequence, GtkButton *button) { + GtkButtonPrivate *priv = gtk_button_get_instance_private (button); + + if (priv->activate_timeout) + gtk_button_finish_activate (button, FALSE); + gtk_button_do_release (button, FALSE); } @@ -935,22 +937,6 @@ gtk_button_state_flags_changed (GtkWidget *widget, gtk_button_do_release (button, FALSE); } -static void -gtk_button_grab_notify (GtkWidget *widget, - gboolean was_grabbed) -{ - GtkButton *button = GTK_BUTTON (widget); - GtkButtonPrivate *priv = gtk_button_get_instance_private (button); - - GTK_WIDGET_CLASS (gtk_button_parent_class)->grab_notify (widget, was_grabbed); - - if (was_grabbed && priv->activate_timeout) - gtk_button_finish_activate (button, FALSE); - - if (!was_grabbed) - gtk_button_do_release (button, FALSE); -} - /** * gtk_button_set_icon_name: * @button: A #GtkButton -- 2.30.2